/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Controller;

import ControllerInterface.IControllerProgressMap;
import ControllerInterface.IControllerSchemaMapping;
import ViewInterface.AbstractViewMapFactory;
import ViewInterface.IViewProgressMap;
import javax.swing.DefaultListModel;

/**
 *
 * @author Fabian
 */
public class ControllerProgressMap implements IControllerProgressMap {

   private DefaultListModel modeloLista;
   private IControllerSchemaMapping myControlador;
   private IViewProgressMap vistaProgreso;
   private int maxOps;

   
   /**
    * 
    * @param estado
    * @param cantOp
    */
   @Override
    public void newState(String estado, int cantOp) {
        modeloLista.addElement(estado);
        vistaProgreso.addProgress(modeloLista, cantOp);
    }

    /**
     * 
     */
    @Override
    public void cancelMap() {
        this.myControlador.cancelMap();
    }

    /**
     * 
     * @param controlador
     */
    @Override
    public void setController(IControllerSchemaMapping controlador) {
        myControlador = controlador;
        modeloLista = new DefaultListModel();
        vistaProgreso = AbstractViewMapFactory.getAbstractViewMapFactory().getVistaProgreso();
        vistaProgreso.setController(this);
        vistaProgreso.addProgress(modeloLista, 0);
        vistaProgreso.setVisibleViewProgress(true);
    }

    /**
     * 
     */
    @Override
    public void finish() {
        vistaProgreso.finish();
    }
    
    /**
     * 
     * @param maxOp
     */
    @Override
    public void setMaxOp(int maxOp) {
        maxOps = maxOp;
        vistaProgreso.setMaxOp(maxOps);
    }
    
}
